<div class="nav-header layui-bg-black">
    <div class="layui-main">
        <div class="nav-logo">
            <img src="/static/res/img/icon.png">
        </div>
        <ul class="layui-nav">
            <li id="nav-index" class="layui-nav-item nav-header-height"><a href="javascript:changeNav(0);">首页</a></li>
            <li id="nav-menu-manager" class="layui-nav-item nav-header-height layui-hide-xs"><a href="javascript:changeNav(1);">菜单管理</a></li>
            <li id="nav-member-manager" class="layui-nav-item nav-header-height"><a href="javascript:changeNav(2);">用户管理</a></li>
            <li id="nav-notice-center" class="layui-nav-item nav-header-height"><a href="javascript:changeNav(3);">消息中心<span id="notice_num" class="layui-badge" style="display: none">0</span></a></li>
            <li id="nav-settings" class="layui-nav-item nav-header-height layui-hide-xs"><a href="javascript:changeNav(4)">设置</a></li>
        </ul>
    </div>
</div>
<script>
    var parentUrl = window.parent.document.URL;
    var targetId = '';
    var current_page = 0;
    if (parentUrl.indexOf("Index") > 0) {
        targetId = "nav-index";
        current_page = 0;
    } else if (parentUrl.indexOf("MenuManager") > 0) {
        targetId = "nav-menu-manager";
        current_page = 1;
    } else if (parentUrl.indexOf("UserManager") > 0 || parentUrl.indexOf("RoleManager") > 0) {
        targetId = "nav-member-manager";
        current_page = 2;
    } else if (parentUrl.indexOf("NoticeCenter") > 0) {
        targetId = "nav-notice-center";
        current_page = 3;
    } else if (parentUrl.indexOf("Settings") > 0) {
        targetId = "nav-settings";
        current_page = 4;
    }
    var target_className = document.getElementById(targetId).className;
    target_className +=  " layui-this";
    document.getElementById(targetId).className = target_className;

    function changeNav(position) {
        if (current_page == position) return;

        switch (position) {
            case 0:
                window.parent.location.href='../index/Index.html';
                break;
            case 1:
                window.parent.location.href='../index/MenuManager.html';
                break;
            case 2:
                window.parent.location.href='../member_manager/UserList.html';
                break;
            case 3:
                window.parent.location.href='../index/NoticeCenter.html';
                break;
            case 4:
                window.parent.location.href='../index/Settings.html';
                break;
        }
    }

    //注意：导航 依赖 element 模块，否则无法进行功能性操作
    layui.use('element', function(){
//        var element = layui.element;
//        console.log("111111");
//        console.log(element);
    });
</script>